import { Controller, Get, Post, Body, Param } from '@nestjs/common';
import { PermissionsService } from './permissions.service';
import { CreatePermissionDto } from './dto/create-permission.dto';
import { UpdatePermissionDto } from './dto/update-permission.dto';
import { ApiOperation, ApiTags } from '@nestjs/swagger';

@ApiTags('权限')
@Controller('permissions')
export class PermissionsController {
  constructor(private readonly permissionsService: PermissionsService) {}

  @ApiOperation({ summary: '创建权限' })
  @Post('create')
  create(@Body() createPermissionDto: CreatePermissionDto) {
    return this.permissionsService.create(createPermissionDto);
  }

  @ApiOperation({ summary: '查询所有权限' })
  @Get('queryAll')
  findAll() {
    return this.permissionsService.findAll();
  }

  @ApiOperation({ summary: '查询权限' })
  @Get('query/:id')
  findOne(@Param('id') id: string) {
    return this.permissionsService.findOne(+id);
  }

  @ApiOperation({ summary: '编辑权限' })
  @Post('update/:id')
  update(
    @Param('id') id: string,
    @Body() updatePermissionDto: UpdatePermissionDto,
  ) {
    return this.permissionsService.update(+id, updatePermissionDto);
  }

  @ApiOperation({ summary: '删除权限' })
  @Post('remove/:id')
  remove(@Param('id') id: string) {
    return this.permissionsService.remove(+id);
  }
}
